/*
               File: C47
        Description: Conversion for table MMPRF20
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 27 de Setiembre de 2010 16:9:35.10
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class c47 extends GXProcedure
{
   public c47( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( c47.class ), "" );
   }

   public c47( int remoteHandle ,
               ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( )
   {
      execute_int();
   }

   private void execute_int( )
   {
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      /* Using cursor C472 */
      pr_default.execute(0);
      while ( (pr_default.getStatus(0) != 101) )
      {
         A519MVehCo = C472_A519MVehCo[0] ;
         A517PrfTim = C472_A517PrfTim[0] ;
         A516PrfTlf = C472_A516PrfTlf[0] ;
         A515PrfTlf = C472_A515PrfTlf[0] ;
         A514PrfTlf = C472_A514PrfTlf[0] ;
         A513PrfDir = C472_A513PrfDir[0] ;
         A512PrfDir = C472_A512PrfDir[0] ;
         A511PrfNro = C472_A511PrfNro[0] ;
         A510PrfPre = C472_A510PrfPre[0] ;
         A489SerCod = C472_A489SerCod[0] ;
         A258EmpCod = C472_A258EmpCod[0] ;
         A35PrsCod = C472_A35PrsCod[0] ;
         A507PrfCod = C472_A507PrfCod[0] ;
         A500PrfCod = C472_A500PrfCod[0] ;
         /*
            INSERT RECORD ON TABLE GXA0047

         */
         AV2PrfCod = A500PrfCod ;
         AV3PrfCodL = A507PrfCod ;
         if ( C472_n35PrsCod[0] )
         {
            AV4PrsCod = "" ;
         }
         else
         {
            AV4PrsCod = A35PrsCod ;
         }
         if ( C472_n258EmpCod[0] )
         {
            AV5EmpCod = "" ;
         }
         else
         {
            AV5EmpCod = A258EmpCod ;
         }
         if ( C472_n489SerCod[0] )
         {
            AV6SerCod = 0 ;
         }
         else
         {
            AV6SerCod = A489SerCod ;
         }
         if ( C472_n510PrfPre[0] )
         {
            AV7PrfPreS = 0 ;
         }
         else
         {
            AV7PrfPreS = A510PrfPre ;
         }
         if ( C472_n511PrfNro[0] )
         {
            AV8PrfNroD = "" ;
         }
         else
         {
            AV8PrfNroD = A511PrfNro ;
         }
         if ( C472_n512PrfDir[0] )
         {
            AV9PrfDirL = "" ;
         }
         else
         {
            AV9PrfDirL = A512PrfDir ;
         }
         if ( C472_n513PrfDir[0] )
         {
            AV10PrfDir = "" ;
         }
         else
         {
            AV10PrfDir = A513PrfDir ;
         }
         if ( C472_n514PrfTlf[0] )
         {
            AV11PrfTlf = "" ;
         }
         else
         {
            AV11PrfTlf = A514PrfTlf ;
         }
         if ( C472_n515PrfTlf[0] )
         {
            AV12PrfTlf = "" ;
         }
         else
         {
            AV12PrfTlf = A515PrfTlf ;
         }
         if ( C472_n516PrfTlf[0] )
         {
            AV13PrfTlf = "" ;
         }
         else
         {
            AV13PrfTlf = A516PrfTlf ;
         }
         if ( C472_n517PrfTim[0] )
         {
            AV14PrfTim = 0 ;
         }
         else
         {
            AV14PrfTim = A517PrfTim ;
         }
         if ( C472_n519MVehCo[0] )
         {
            AV15MVehCo = 0 ;
         }
         else
         {
            AV15MVehCo = A519MVehCo ;
         }
         /* Using cursor C473 */
         pr_default.execute(1, new Object[] {new Long(AV2PrfCod), new Short(AV3PrfCodL), AV4PrsCod, AV5EmpCod, new Long(AV6SerCod), new Double(AV7PrfPreS), AV8PrfNroD, AV9PrfDirL, AV10PrfDir, AV11PrfTlf, AV12PrfTlf, AV13PrfTlf, new Integer(AV14PrfTim), new Short(AV15MVehCo)});
         if ( (pr_default.getStatus(1) == 1) )
         {
            Gx_err = (short)(1) ;
            Gx_emsg = localUtil.getMessages().getMessage("noupdate") ;
         }
         else
         {
            Gx_err = 0 ;
            Gx_emsg = "" ;
         }
         /* End Insert */
         pr_default.readNext(0);
      }
      pr_default.close(0);
      cleanup();
   }

   protected void cleanup( )
   {
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      C472_A519MVehCo = new short[1] ;
      C472_A517PrfTim = new int[1] ;
      C472_A516PrfTlf = new String[] {""} ;
      C472_A515PrfTlf = new String[] {""} ;
      C472_A514PrfTlf = new String[] {""} ;
      C472_A513PrfDir = new String[] {""} ;
      C472_A512PrfDir = new String[] {""} ;
      C472_A511PrfNro = new String[] {""} ;
      C472_A510PrfPre = new double[1] ;
      C472_A489SerCod = new long[1] ;
      C472_A258EmpCod = new String[] {""} ;
      C472_A35PrsCod = new String[] {""} ;
      C472_A507PrfCod = new short[1] ;
      C472_A500PrfCod = new long[1] ;
      A519MVehCo = 0 ;
      A517PrfTim = 0 ;
      A516PrfTlf = "" ;
      A515PrfTlf = "" ;
      A514PrfTlf = "" ;
      A513PrfDir = "" ;
      A512PrfDir = "" ;
      A511PrfNro = "" ;
      A510PrfPre = 0 ;
      A489SerCod = 0 ;
      A258EmpCod = "" ;
      A35PrsCod = "" ;
      A507PrfCod = 0 ;
      A500PrfCod = 0 ;
      GIGXA0047 = 0 ;
      AV2PrfCod = 0 ;
      AV3PrfCodL = 0 ;
      C472_n35PrsCod = new boolean[] {false} ;
      AV4PrsCod = "" ;
      C472_n258EmpCod = new boolean[] {false} ;
      AV5EmpCod = "" ;
      C472_n489SerCod = new boolean[] {false} ;
      AV6SerCod = 0 ;
      C472_n510PrfPre = new boolean[] {false} ;
      AV7PrfPreS = 0 ;
      C472_n511PrfNro = new boolean[] {false} ;
      AV8PrfNroD = "" ;
      C472_n512PrfDir = new boolean[] {false} ;
      AV9PrfDirL = "" ;
      C472_n513PrfDir = new boolean[] {false} ;
      AV10PrfDir = "" ;
      C472_n514PrfTlf = new boolean[] {false} ;
      AV11PrfTlf = "" ;
      C472_n515PrfTlf = new boolean[] {false} ;
      AV12PrfTlf = "" ;
      C472_n516PrfTlf = new boolean[] {false} ;
      AV13PrfTlf = "" ;
      C472_n517PrfTim = new boolean[] {false} ;
      AV14PrfTim = 0 ;
      C472_n519MVehCo = new boolean[] {false} ;
      AV15MVehCo = 0 ;
      Gx_err = 0 ;
      Gx_emsg = "" ;
      pr_default = new DataStoreProvider(context, remoteHandle, new c47__default(),
         new Object[] {
             new Object[] {
            C472_A519MVehCo, C472_n519MVehCo, C472_A517PrfTim, C472_n517PrfTim, C472_A516PrfTlf, C472_n516PrfTlf, C472_A515PrfTlf, C472_n515PrfTlf, C472_A514PrfTlf, C472_n514PrfTlf,
            C472_A513PrfDir, C472_n513PrfDir, C472_A512PrfDir, C472_n512PrfDir, C472_A511PrfNro, C472_n511PrfNro, C472_A510PrfPre, C472_n510PrfPre, C472_A489SerCod, C472_n489SerCod,
            C472_A258EmpCod, C472_n258EmpCod, C472_A35PrsCod, C472_n35PrsCod, C472_A507PrfCod, C472_A500PrfCod
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private short A519MVehCo ;
   private short A507PrfCod ;
   private short AV3PrfCodL ;
   private short AV15MVehCo ;
   private short Gx_err ;
   private int A517PrfTim ;
   private int GIGXA0047 ;
   private int AV14PrfTim ;
   private long A489SerCod ;
   private long A500PrfCod ;
   private long AV2PrfCod ;
   private long AV6SerCod ;
   private double A510PrfPre ;
   private double AV7PrfPreS ;
   private String A516PrfTlf ;
   private String A515PrfTlf ;
   private String A514PrfTlf ;
   private String A513PrfDir ;
   private String A512PrfDir ;
   private String A511PrfNro ;
   private String A258EmpCod ;
   private String A35PrsCod ;
   private String AV4PrsCod ;
   private String AV5EmpCod ;
   private String AV8PrfNroD ;
   private String AV9PrfDirL ;
   private String AV10PrfDir ;
   private String AV11PrfTlf ;
   private String AV12PrfTlf ;
   private String AV13PrfTlf ;
   private String Gx_emsg ;
   private IDataStoreProvider pr_default ;
   private short[] C472_A519MVehCo ;
   private int[] C472_A517PrfTim ;
   private String[] C472_A516PrfTlf ;
   private String[] C472_A515PrfTlf ;
   private String[] C472_A514PrfTlf ;
   private String[] C472_A513PrfDir ;
   private String[] C472_A512PrfDir ;
   private String[] C472_A511PrfNro ;
   private double[] C472_A510PrfPre ;
   private long[] C472_A489SerCod ;
   private String[] C472_A258EmpCod ;
   private String[] C472_A35PrsCod ;
   private short[] C472_A507PrfCod ;
   private long[] C472_A500PrfCod ;
   private boolean[] C472_n35PrsCod ;
   private boolean[] C472_n258EmpCod ;
   private boolean[] C472_n489SerCod ;
   private boolean[] C472_n510PrfPre ;
   private boolean[] C472_n511PrfNro ;
   private boolean[] C472_n512PrfDir ;
   private boolean[] C472_n513PrfDir ;
   private boolean[] C472_n514PrfTlf ;
   private boolean[] C472_n515PrfTlf ;
   private boolean[] C472_n516PrfTlf ;
   private boolean[] C472_n517PrfTim ;
   private boolean[] C472_n519MVehCo ;
}

final class c47__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("C472", "SELECT [MVehCod], [PrfTimEst], [PrfTlfEma], [PrfTlfMov], [PrfTlfFij], [PrfDirUbi], [PrfDirLin], [PrfNroDCho], [PrfPreSer], [SerCod], [EmpCod], [PrsCod], [PrfCodLin], [PrfCod] FROM [MMPRF20] WITH (NOLOCK) ORDER BY [PrfCod], [PrfCodLin] ",false, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("C473", "INSERT INTO [GXA0047] ([PrfCod], [PrfCodLin], [PrsCod], [EmpCod], [SerCod], [PrfPreSer], [PrfNroDCho], [PrfDirLin], [PrfDirUbi], [PrfTlfFij], [PrfTlfMov], [PrfTlfEma], [PrfTimEst], [MVehCod]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((short[]) buf[0])[0] = rslt.getShort(1) ;
               ((boolean[]) buf[1])[0] = rslt.wasNull();
               ((int[]) buf[2])[0] = rslt.getInt(2) ;
               ((boolean[]) buf[3])[0] = rslt.wasNull();
               ((String[]) buf[4])[0] = rslt.getString(3, 100) ;
               ((boolean[]) buf[5])[0] = rslt.wasNull();
               ((String[]) buf[6])[0] = rslt.getString(4, 20) ;
               ((boolean[]) buf[7])[0] = rslt.wasNull();
               ((String[]) buf[8])[0] = rslt.getString(5, 20) ;
               ((boolean[]) buf[9])[0] = rslt.wasNull();
               ((String[]) buf[10])[0] = rslt.getString(6, 6) ;
               ((boolean[]) buf[11])[0] = rslt.wasNull();
               ((String[]) buf[12])[0] = rslt.getString(7, 200) ;
               ((boolean[]) buf[13])[0] = rslt.wasNull();
               ((String[]) buf[14])[0] = rslt.getString(8, 15) ;
               ((boolean[]) buf[15])[0] = rslt.wasNull();
               ((double[]) buf[16])[0] = rslt.getDouble(9) ;
               ((boolean[]) buf[17])[0] = rslt.wasNull();
               ((long[]) buf[18])[0] = rslt.getLong(10) ;
               ((boolean[]) buf[19])[0] = rslt.wasNull();
               ((String[]) buf[20])[0] = rslt.getString(11, 20) ;
               ((boolean[]) buf[21])[0] = rslt.wasNull();
               ((String[]) buf[22])[0] = rslt.getString(12, 10) ;
               ((boolean[]) buf[23])[0] = rslt.wasNull();
               ((short[]) buf[24])[0] = rslt.getShort(13) ;
               ((long[]) buf[25])[0] = rslt.getLong(14) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 1 :
               stmt.setLong(1, ((Long) parms[0]).longValue());
               stmt.setShort(2, ((Short) parms[1]).shortValue());
               stmt.setString(3, (String)parms[2], 10);
               stmt.setString(4, (String)parms[3], 20);
               stmt.setLong(5, ((Long) parms[4]).longValue());
               stmt.setDouble(6, ((Double) parms[5]).doubleValue());
               stmt.setString(7, (String)parms[6], 15);
               stmt.setString(8, (String)parms[7], 200);
               stmt.setString(9, (String)parms[8], 6);
               stmt.setString(10, (String)parms[9], 20);
               stmt.setString(11, (String)parms[10], 20);
               stmt.setString(12, (String)parms[11], 100);
               stmt.setInt(13, ((Integer) parms[12]).intValue());
               stmt.setShort(14, ((Short) parms[13]).shortValue());
               break;
      }
   }

}

